package com.zhb.cloud.mybatis.sys.service.impl;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import com.zhb.cloud.mybatis.sys.model.Privilege;
import com.zhb.cloud.mybatis.sys.repository.PrivilegeRepository;
import com.zhb.cloud.mybatis.sys.service.PrivilegeService;

/**
 * @Title: PrivilegeServiceImpl.java
 * @Package com.zhb.mybatis.sys.service.impl
 * @Description: 权限管理
 * @author zhb
 * @date 2016年8月3日 下午3:28:46
 * @version V1.0
 */
@Service
@Transactional
public class PrivilegeServiceImpl implements PrivilegeService {
	@Autowired
	private PrivilegeRepository privilegeRepository;

	@Override
	public Privilege findById(String id) {
		return privilegeRepository.findOne(id);
	}

	@Override
	public Privilege saveModel(Privilege model) {
		return privilegeRepository.save(model);
	}

	@Override
	public Privilege updateModel(Privilege model) {
		return privilegeRepository.saveAndFlush(model);

	}

	@Override
	public void deleteModel(String id) {
		privilegeRepository.delete(id);
	}

	@Override
	public long totalAmount(Privilege model, Object... objects) {
		return 0;
	}

	@Override
	public Page<Privilege> selectModelByCondition(int pageNum, int pageSize) {
		return privilegeRepository.findAll(new PageRequest(pageNum, pageSize));
	}

}
